<!DOCTYPE html>
<html lang="en">
<head>
    <title>Hello World</title>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
    <script>

        $(function () {
            $("#click").click(function () {
                $.ajax({
                    url:'login',
                    type:'POST', //GET
                    data:{
                        username:'gzq9425',password:'123'
                    },
                    timeout:5000,    //超时时间
                    dataType:'json',    //返回的数据格式：json/xml/html/script/jsonp/text
                    beforeSend:function(xhr){
                        console.log(xhr)
                        console.log('before')
                    },
                    success:function(data,textStatus,jqXHR){
                        console.log(data)
                        console.log(textStatus)
                        console.log(jqXHR)
                    },
                    error:function(xhr,textStatus){
                        console.log('false')
                        console.log(xhr)
                        console.log(textStatus)
                    },
                    complete:function(){
                        console.log('end')
                    }
                })
            });
            $("#click2").click(function () {
                var websocket = new WebSocket('ws://localhost:8080/websocket?room=1')
            })
        });
    </script>
</head>

    <input name="username" id="username"> <br/>
    <input type="password" name="password" id="password"/><br/>
    <button id="click" >clickMe</button>
    <button id="click2">clickMe2</button>

<body>


</body>
</html>